//
//  QBWTRCell.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/18.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "QBWTRCell.h"

@implementation QBWTRCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initSubView];
        [self layout];
    }
    return self;
}
- (void)initSubView{
    [self addSubview:self.backView];
    [_backView addSubview:self.leftImageView];
    [_backView addSubview:self.headerImageView];
    [_backView addSubview:self.nameLabel];
    [_backView addSubview:self.dateLabel];
    [_backView addSubview:self.lineView];
}
- (void)layout{
    [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@18);
        make.right.equalTo(@0).offset(-18);
        make.top.equalTo(@20);
        make.bottom.equalTo(@0).offset(0);
    }];
    [_leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@12);
        make.centerY.equalTo(self.backView.mas_centerY);
        make.width.equalTo(@0).offset(147*fw);
        make.height.equalTo(@0).offset(98*fh);
    }];
    [_headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftImageView.mas_right).offset(10);
        make.top.equalTo(self.leftImageView.mas_top);
        make.width.equalTo(@30);
        make.height.equalTo(@30);
    }];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headerImageView.mas_right).offset(10);
        make.centerY.equalTo(self.headerImageView.mas_centerY);
        make.width.equalTo(@60);
        make.height.equalTo(@15);
    }];
    [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@0).offset(-10);
        make.centerY.equalTo(self.headerImageView.mas_centerY);
        make.left.equalTo(self.nameLabel.mas_right);
        make.height.equalTo(@15);
    }];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@0).offset(-10);
        make.top.equalTo(self.headerImageView.mas_bottom).offset(13);
        make.left.equalTo(self.headerImageView.mas_left);
        make.height.equalTo(@1);
    }];
}
- (UIView *)backView{
    if (!_backView) {
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = [UIColorChange colorwithHexString:@"#F8F8F8"];
        _backView = view;
    }
    return _backView;
}
- (UIView *)lineView{
    if (!_lineView) {
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = [UIColor lightGrayColor];
        _lineView = view;
    }
    return _lineView;
}
- (UIImageView *)leftImageView{
    if (!_leftImageView) {
        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.backgroundColor = [UIColor lightGrayColor];
        _leftImageView = imageView;
    }
    return _leftImageView;
}
- (UIImageView *)headerImageView{
    if (!_headerImageView) {
        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.backgroundColor = [UIColor lightGrayColor];
        imageView.layer.cornerRadius = 15;
        imageView.layer.masksToBounds = YES;
        _headerImageView = imageView;
    }
    return _headerImageView;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"王子怡";
        label.textColor = SELECTEDCOLOR;
        label.font = [UIFont systemFontOfSize:14];
        _nameLabel = label;
    }
    return _nameLabel;
}
- (UILabel *)dateLabel{
    if (!_dateLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"2019-03-27 10:08";
        label.textColor = [UIColorChange colorwithHexString:@"#999999"];
        label.font = [UIFont systemFontOfSize:14];
        label.textAlignment = 2;
        _dateLabel = label;
    }
    return _dateLabel;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
